/*
 * types.h
 *
 *  Created on: 26/mag/2014
 *      Author: PegorarS
 */

#ifndef TYPES_H_
#define TYPES_H_



typedef	float	PERCENT;
typedef	float	PRICE;
typedef float	CASH;
typedef float	VOLUME;
typedef char *	Ticker;
typedef enum{
	POS_LONG,
	POS_SHORT
}POSITION_TYPE;


struct Date{
	static const int monthSize[];

	int year;
	int month;
	int day;
	enum WEEKDAY{
		MONDAY,
		TUESDAY,
		WEDNESDAY,
		THURSDAY,
		FRIDAY,
		SATURDAY,
		SUNDAY
	}weekDay;
	int hour;
	int min;
	int sec;

	Date(){
		year = 0;
		month = 0;
		day = 0;
		weekDay = SUNDAY;
		hour = 0;
		min = 0;
		sec = 0;
	}

	Date(char * strDate){ //TODO: fare il parsing di strDate
	}

	Date operator++(int unused){
		Date ret = *this;
		IncDay();

		return ret;
	}

	Date &operator++(){
		IncDay();
		return *this;
	}

private:
	void IncDay(){
		int leap = ((year % 400 == 0) || ((year % 100 != 0) && (year % 4 == 0))) ? ((month == 2) ? 1 : 0) : 0;
		if(++day >= monthSize[month] + leap){
			if(++month >= 12){
				month = 0;
				year++;
			}
		}
		if(weekDay == SUNDAY)
			weekDay = MONDAY;
		else{
			int tmp = (int)weekDay;
			tmp++;
			weekDay = (enum WEEKDAY)tmp;
		}
	}
};



#endif /* TYPES_H_ */
